package com.yss.job.domain;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yss.common.core.annotation.EasyExcel;
import com.yss.common.core.utils.easyexecl.IntegerConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 定时任务调度日志表 sys_job_log
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_job_log")
public class SysJobLog extends Model<SysJobLog> {
    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @ExcelIgnore
    @TableId("ID")
    private String id;

    /**
     * 任务名称
     */
    @ExcelProperty(value = "任务名称")
    @TableField("JOB_NAME")
    private String jobName;

    /**
     * 任务组名
     */
    @ExcelProperty(value = "任务组名")
    @TableField("JOB_GROUP")
    private String jobGroup;

    /**
     * 调用目标字符串
     */
    @ExcelProperty(value = "调用目标字符串")
    @TableField("INVOKE_TARGET")
    private String invokeTarget;

    /**
     * 日志信息
     */
    @ExcelProperty(value = "日志信息")
    @TableField("JOB_MESSAGE")
    private String jobMessage;

    /**
     * 执行状态（0正常 1失败）
     */
    @ExcelProperty(value = "状态", converter = IntegerConverter.class)
    @EasyExcel(readConverterExp = "1=正常,2=停用")
    @TableField("STATUS")
    private Integer status;

    /**
     * 异常信息
     */
    @ExcelProperty(value = "异常信息")
    @TableField("EXCEPTION_INFO")
    private String exceptionInfo;
    /**
     * 创建时间
     */
    @TableField("CREATE_TIME")
    private Date createTime;
    /**
     * 开始时间
     */
    @ExcelIgnore
    @TableField(exist = false)
    private Date startTime;

    /**
     * 停止时间
     */
    @ExcelIgnore
    @TableField(exist = false)
    private Date stopTime;

    /**
     * 搜索值
     */
    @JsonIgnore
    @ExcelIgnore
    @TableField(exist = false)
    private String searchValue;
    /**
     * 请求参数
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @ExcelIgnore
    @TableField(exist = false)
    private Map<String, Object> params;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }
}
